/**
 * @author Luc Yriarte
 * 
 * Licence : BSD http://www.opensource.org/licenses/bsd-license.php
 *  
 */
package calcApplet;

import java.applet.Applet;
import java.awt.Button;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import basicSim.Matrix;

public class MatrixCalc extends Applet implements ActionListener {
	Matrix m1, m2, mr;

	TextField arg1, arg2, res;

	Button add, mul, inv;

	public void init() {
		arg1 = new TextField(30);
		arg2 = new TextField(30);
		res = new TextField(30);
		add = new Button("+");
		mul = new Button("*");
		inv = new Button("inv");
	}

	public void start() {
		add(arg1);
		add(arg2);
		add(add);
		add.addActionListener(this);
		add(mul);
		mul.addActionListener(this);
		add(inv);
		inv.addActionListener(this);
		add(res);
		arg1.setText(((new Matrix(3, 3)).toId()).toString());
		arg2.setText(((new Matrix(3, 3)).toId()).toString());
		repaint();
	}

	public void actionPerformed(ActionEvent e) {
/* Java 2
		Object src = e.getSource();
		m1 = new Matrix(arg1.getText());
		m2 = new Matrix(arg2.getText());
		if (src == add) {
			mr = m1.add(m2);
		} else if (src == mul) {
			mr = m1.mul(m2);
		} else if (src == inv) {
			mr = m1.inv();
		}
		res.setText(mr.toString());
*/
	}
}
